package com.backend.system.util;

import com.backend.system.common.processor.AbstractProcessorTemplate;
import com.backend.system.common.processor.ProcessorContext;
import com.backend.system.common.processor.ProcessorFactory;

/**
 * 管理工具
 *
 * @author feng
 */
public class ManagerUtil {
    public static <R, T> R handle(ProcessorContext<T> context) {
        AbstractProcessorTemplate<T, R> processor = ProcessorFactory.getProcessor(context.getAction());
        if (processor == null) {
            throw new RuntimeException("未找到 " + context.getAction() + "对应的处理器");
        }
        return processor.start(context);
    }
}

